﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.XtraRichEdit.Model;

namespace TheheVn.AdminPage
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        public const string SESSION_USER = "SessionUser";
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btOk_Click(object sender, EventArgs e)
        {
            using (var ent = new Entities())
            {
                var data = ent.Admins.FirstOrDefault(p => p.UserName == txtName.Text && p.Password == txtPwd.Text);
                if (data != null)
                {
                    Session[SESSION_USER] = data;
                    Response.Redirect("PageManager.aspx");
                }
                else
                {
                    txtName.Text = "";
                    txtPwd.Text = "";
                }
            }
        }
    }
}